package com.espressif.iot.db.greenrobot.daos;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.espressif.iot.db.greenrobot.daos.UserDBDao;
import com.espressif.iot.db.greenrobot.daos.DeviceDBDao;
import com.espressif.iot.db.greenrobot.daos.GroupDBDao;
import com.espressif.iot.db.greenrobot.daos.GroupLocalDeviceDBDao;
import com.espressif.iot.db.greenrobot.daos.GroupCloudDeviceDBDao;
import com.espressif.iot.db.greenrobot.daos.GroupRemoveDeviceDBDao;
import com.espressif.iot.db.greenrobot.daos.ApDBDao;
import com.espressif.iot.db.greenrobot.daos.DownloadIdValueDBDao;
import com.espressif.iot.db.greenrobot.daos.GenericDataDirectoryDBDao;
import com.espressif.iot.db.greenrobot.daos.GenericDataDBDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 21): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 21;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        UserDBDao.createTable(db, ifNotExists);
        DeviceDBDao.createTable(db, ifNotExists);
        GroupDBDao.createTable(db, ifNotExists);
        GroupLocalDeviceDBDao.createTable(db, ifNotExists);
        GroupCloudDeviceDBDao.createTable(db, ifNotExists);
        GroupRemoveDeviceDBDao.createTable(db, ifNotExists);
        ApDBDao.createTable(db, ifNotExists);
        DownloadIdValueDBDao.createTable(db, ifNotExists);
        GenericDataDirectoryDBDao.createTable(db, ifNotExists);
        GenericDataDBDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        UserDBDao.dropTable(db, ifExists);
        DeviceDBDao.dropTable(db, ifExists);
        GroupDBDao.dropTable(db, ifExists);
        GroupLocalDeviceDBDao.dropTable(db, ifExists);
        GroupCloudDeviceDBDao.dropTable(db, ifExists);
        GroupRemoveDeviceDBDao.dropTable(db, ifExists);
        ApDBDao.dropTable(db, ifExists);
        DownloadIdValueDBDao.dropTable(db, ifExists);
        GenericDataDirectoryDBDao.dropTable(db, ifExists);
        GenericDataDBDao.dropTable(db, ifExists);
    }

    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO",
                "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(UserDBDao.class);
        registerDaoClass(DeviceDBDao.class);
        registerDaoClass(GroupDBDao.class);
        registerDaoClass(GroupLocalDeviceDBDao.class);
        registerDaoClass(GroupCloudDeviceDBDao.class);
        registerDaoClass(GroupRemoveDeviceDBDao.class);
        registerDaoClass(ApDBDao.class);
        registerDaoClass(DownloadIdValueDBDao.class);
        registerDaoClass(GenericDataDirectoryDBDao.class);
        registerDaoClass(GenericDataDBDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

}
